home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / modelers / geomview / source.lha / Geomview / src / lib / gprim / inst / instsphere.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-16  |  705 b   |  32 lines

  1. #include "geom.h"
  2. #include "create.h"
  3. #include "instP.h"
  4. #include "sphere.h"
  5.  
  6. Geom *InstBoundSphere(inst, T, space)
  7.      Inst *inst;
  8.      Transform T;
  9.      int space;
  10. {
  11.   register Sphere *geomsphere, *sphere;
  12.   Transform Tnew;
  13.   GeomIter *it;
  14.  
  15.   if (inst == NULL || inst->geom == NULL) return NULL;
  16.  
  17.   it = GeomIterate((Geom *)inst, DEEP);
  18.   geomsphere = NULL;
  19.   while (NextTransform(it, Tnew) > 0) {
  20.     TmConcat(Tnew, T, Tnew);
  21.     sphere = (Sphere *)GeomBoundSphere(inst->geom, Tnew, space);
  22.     if (sphere != NULL) {
  23.       if (geomsphere != NULL) {
  24.     SphereUnion3(geomsphere, sphere, geomsphere);
  25.     GeomDelete((Geom *)sphere);
  26.       } else geomsphere = sphere;
  27.     }
  28.   }
  29.  
  30.   return (Geom *)geomsphere;
  31. }
  32.